import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    name: 'Home',
    component: Home,
    redirect: '/index',
    children: [{
        path: '/index',
        name: 'Index',
        component: () => import('../views/Index.vue')
      },
      {
        path: '/product/:id',
        name: 'Product',
        component: () => import('../views/Product.vue')
      },
      {
        path: '/detail/:id',
        name: 'Detail',
        component: () => import('../views/Detail.vue')
      },

    ]
  },
  {
    path: '/card',
    name: 'Card',
    component: () => import('../views/Card.vue'),
    meta: {
      requireAuth: true
    },
  },

  {
    path: '/order',
    name: 'Order',
    component: () => import('../views/Order.vue'),
    children: [{
        path: '/order/orderconfirm',
        name: 'OrderConfirm',
        component: () => import('../views/OrderConfirm.vue')
      },
      {
        path: '/order/orderlist',
        name: 'OrderList',
        component: () => import('../views/OrderList.vue')
      },
      {
        path: '/order/orderpay',
        name: 'OrderPay',
        component: () => import('../views/OrderPay.vue')
      },
    ],
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue'),

  },
  {
    path: '/zhuce',
    name: 'Zhuce',
    component: () => import('../views/Zhuce.vue'),
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../views/Register.vue'),
  },
  {
    path: '/shiyan',
    name: 'Shiyan',
    component: () => import('../views/Shiyan.vue'),

  },
  {
    path: '/alex',
    name: 'Alex',
    component: () => import('../views/Alex.vue'),

  },
]

const router = new VueRouter({
  routes,
  scrollBehavior(to, from, savedPosition) {
    return {
      x: 0,
      y: 0
    }
  }
})

export default router